home *** CD-ROM | disk | FTP | other *** search
/ Aminet 32 / Aminet 32 (1999)(Schatztruhe)[!][Aug 1999].iso / Aminet / dev / c / SUPRALib.lha / SUPRALib / Developer / Source / mkImg.a < prev    next >
Text File  |  1999-05-17  |  2KB  |  91 lines

  1. ; This is a planar --> chunky --> planar routine used for
  2. ; MakeNewImg() function.
  3.  
  4.     xdef _mkImg
  5.  
  6.     section code
  7. _mkImg:
  8. ;A1 - start of a source bitplane
  9. ;A2 - start of a destination bitplane
  10. ;A3 - palette list
  11. ;
  12. ;D4 - size of one bit plane
  13. ;D5 - source depth
  14. ;D6 - destination depth
  15. ;
  16. ;internals:
  17. ;A1 - current position on a source bitplane
  18. ;A2 - current pos. on a dest. bitplane
  19. ;D3 - end of the first bitplane
  20. ;D7 - color palete byte
  21. ;also reserved are: A0, D0, D1
  22.  
  23.     move.l  a1,d3   ;end of the first bitplane -->d3
  24.     add.l   d4,d3
  25.  
  26. st1:
  27.     moveq   #7,d0   ;bit position (goes from 7 to 0)
  28.  
  29. st2:
  30.     clr     d7
  31.     clr     d1
  32.  
  33.  
  34. source:                 ; this computes a chunky byte from source planes
  35.     bsr     getsrcbyte  ; fills A0 with D1-th plane
  36.     btst    d0,(a0)
  37.     beq     set0
  38.     bset    d1,d7
  39. set0:
  40.     addq.w  #1,d1
  41.     cmp.w   d1,d5
  42.     bgt     source
  43.  
  44.  
  45.     lsl.w   #2,d7           ;*4 for palette has long entries
  46.     move.l  $0(a3,d7.w),d7  ;gets the new color
  47.     clr     d1
  48.  
  49. dest:                   ;this modifies planar planes into the new color
  50.     bsr     getdestbyte
  51.     btst    d1,d7
  52.     beq     dest0
  53.     bset    d0,(a0)
  54. dest0:
  55.     addq.w  #1,d1
  56.     cmp.w   d1,d6
  57.     bgt     dest
  58.  
  59.  
  60.     subq.b  #1,d0       ;still in the same byte (7 to 0)? loop!
  61.     bge     st2
  62.  
  63.     addq    #1,a1
  64.     addq    #1,a2
  65.     cmp.l   a1,d3
  66.     bgt     st1         ;loop until end of planes
  67.  
  68.     rts
  69.  
  70. getsrcbyte:
  71.     tst.b   d1
  72.     beq     srcyes
  73.     add.l   d4,a0
  74.     rts
  75. srcyes:
  76.     move.l  a1,a0
  77.     rts
  78.     
  79. getdestbyte:
  80.     tst.b   d1
  81.     beq     destyes
  82.     add.l   d4,a0
  83.     rts
  84. destyes:
  85.     move.l  a2,a0
  86.     rts
  87.         
  88.     end
  89.  
  90.  
  91.